<template>

	<gui-page :customHeader='true'>
		<template v-slot:gBody>
			<!-- 顶部搜索栏 -->
			<!-- <Head :headBack="head_back" :showPopup="showPopup" :greeting="greeting" :weather="weather"></Head> -->
			
			<Head :user="user" :weather="weather" :greeting="greeting" />
			<!-- 快捷功能区 -->
			<scroll-view scroll-y="true" @scroll="scroll" @scrolltoupper="scrolltoupper" style="padding-top: 99rpx;"
				:style="{'margin-top':head_height}">
				<view class="quick-functions" style="background-image: url('http://oss.boyaltd.cn/app/Pcw8PF_myhrnT_bj.png')">
					<view class="functions-wrap">
						<view class="function-item" v-for="item in functionItems" :key="item.id"
							@tap="handleFunctionTap(item)">
							<image class="function-icon" :src="item.icon" mode="aspectFit"></image>
							<text class="function-text">{{ item.text }}</text>
						</view>
					</view>
					<!-- 悬浮客服按钮 -->
				<image
					class="swiper-customer-btn"
					src="http://oss.boyaltd.cn/app/sjZD2X_X74F8t_客服.png"
					mode="aspectFit"
					@tap="onCustomerService"
				></image>
					<!-- 右下角人物图片 -->
					<view class="quick-persons">
						<image class="person-img" src="http://oss.boyaltd.cn/app/Kcncyi_CQYHxP_铁仔.png" mode="aspectFit"></image>
						<image class="person-img" src="/static/img03.png" mode="aspectFit"></image>
					</view>
				</view>
				<!-- <aoEditer v-if="pageConfig" ref="page1" :page="pageConfig" class="app" @event="aoedit_event">
				</aoEditer> -->
			</scroll-view>
			<!-- 轮播图 -->
			<view class="swiper-container">
				<swiper class="swiper" :indicator-dots="true" :autoplay="true" :interval="3000" :duration="500">
					<swiper-item v-for="(item, index) in swiperList" :key="index" @tap="handleSwiperTap(item)">
						<image class="swiper-item" :src="item.src || '/static/homePage/bj1.png'" mode="aspectFill">
						</image>
					</swiper-item>
				</swiper>
				
			</view>

			<!-- 功能导航区 -->
			<view class="function-grid">
				<view class="grid-container">
					<view class="grid-item" v-for="(item, index) in displayedFunctionGrid" :key="index"
						@tap="navigateTo(item, true)">
						<image class="grid-icon" :src="item.icon" mode="aspectFit"></image>
						<text class="grid-text">{{ item.title }}</text>
					</view>
				</view>

				<!-- 展开/收起按钮 -->
				<view v-if="functionGrid && Array.isArray(functionGrid) && functionGrid.length > 10" class="expand-btn"
					@tap="toggleFunctionGrid">
					<uni-icons :type="isGridExpanded ? 'up' : 'down'" size="20" color="#666666"
						class="expand-icon"></uni-icons>
				</view>
			</view>

			<!-- 通知区域 -->
			<view class="notice-section">
				<view class="notice-header" @tap="gonggao">
					<view class="notice-title">
						<image class="title-icon" src="/static/gg.png" mode="aspectFit"></image>
						<!-- <text class="title-text">展无公告</text> -->
						<view class="scroll-container">
							<view id="scroll-text">
								{{noticeText}}暂无公告
							</view>
						</view>
					</view>
					<text class="more-link">更多</text>
				</view>
			</view>
			<!-- 特色专题 -->
			<view class="special-section">
				<view class="section-header section-header-bg">
					<view class="section-title-left">
						<image class="section-logo" src="/static/member/tx.png" mode="aspectFit" style="width: 60rpx;height: 60rpx;"></image>
						<text class="section-text">特色专题</text>
					</view>
				</view>

				<view class="special-content">
					<view class="special-item" v-for="(item, index) in magicCubeRow1" :key="index" @tap="navigateTo(item)">
						<image class="special-icon" style="width:100%;height:100%;position:static;" :src="item.icon" mode="aspectFit"></image>
					</view>
				</view>
				<view class="special-content second-row">
					<view class="special-item" v-for="(item, index) in magicCubeRow2" :key="index" @tap="navigateTo(item)">
						<image class="special-icon" style="width:100%;height:100%;position:static;" :src="item.icon" mode="aspectFit"></image>
					</view>
				</view>
			</view>
			<!-- 图文广告 -->
			<view class="ad-container" v-for="item in adItems" :key="item.id">
				<image class="ad-image" :src="item.image" mode="widthFix" @click="toLink(item.link)"></image>
			</view>
			<!-- 底部版权信息 -->
			<view class="footer-info">
				<text class="copyright">© 柳州博亚科技有限公司 保留所有权利</text>
				<text class="beian">柳钢域名备案号 桂ICP备17009352号</text>
				<text class="beian">桂公网安备4502020200044</text>
				<view class="links">
					<text class="link-item"
						@tap="navigateTo('#/pages/login/agreement/agreement?type=privacy')">隐私政策</text>
					<text class="separator">|</text>
					<text class="link-item" @tap="navigateTo({url: '#/pages/login/agreement/agreement?type=user'})">用户协议</text>
					<text class="separator">|</text>
					<text class="link-item"
						@tap="navigateTo('#/pages/login/agreement/agreement?type=email')">联系我们</text>
				</view>
			</view>
		</template>
		<!-- 右下角人物图片 -->
		<view class="fixed-persons">
			<image class="person-img" src="/static/CQYHxP_铁仔.png" mode="aspectFit"></image>
			<image class="person-img" src="/static/img03.png" mode="aspectFit"></image>
		</view>
	</gui-page>
</template>
<script>
	import cdtDraggrableSort from "@/components/cdt-draggrable-sort/cdt-draggrable-sort.vue"
	import aoEditer from '@/components/common/aoEditer.vue'
	import Head from '@/components/index/Head.vue';
	import sign from "@/Grace6/js/sign.js";
	import {
		nextTick
	} from "vue";
	import config from '@/config.js';
	export default {
		components: {
			aoEditer,
			Head
		},
		data() {
			return {
				// 修改
				swiperList: [],
				// ... existing code ...
				functionGrid: [], // 改为动态获取
				isGridExpanded: false,
				functionItems: [], // 由接口动态赋值
				magicCubeItems: [], // 魔方/特色专题
				adItems: [], // 图文广告
				// ... existing code ...
				user: uni.getStorageSync("userInfo"),
				greeting: '',
				head_height: "-100rpx",
				isEdit: false,
				navList: [],
				pageConfig: uni.getStorageSync("pages_首页"),
				componentlist: [],
				head_back: "",
				showPopup: false,
				newslist: [],
				swiperItems: [],
				isback: false,
				myList: [],
				showTc: false,
				navIndex: 0,
				allList: [],
				debug: false,
				unread: 0,
				is_push: false,
				weather: {
					now: {
						text: "",
						    temp: ""
					}
				},
				opt: null,
				push_id: null,
				noticeText: '', // 修复模板报错
			}
		},
		computed: {
			displayedFunctionGrid() {
				if (!Array.isArray(this.functionGrid)) {
					return [];
				}
				if (this.functionGrid.length <= 10) {
					return this.functionGrid;
				}
				return this.isGridExpanded ? this.functionGrid : this.functionGrid.slice(0, 10);
			},
			magicCubeRow1() {
				return this.magicCubeItems.slice(0, 2);
			},
			magicCubeRow2() {
				return this.magicCubeItems.slice(2, 5);
			}
		},
		// beforeCreate() {

		// },
		// onLoad(opt) {


		// },
		mounted() {
			// 监听返回首页
			// uni.$on('get_unread', this.get_unread);
			// #ifdef APP-PLUS
			this.backButtonListener = this.get_unread.bind(this);
			plus.key.addEventListener('backbutton', this.backButtonListener);
			// #endif
		},
		created() {
			// this.get_menu();
			// this.update_page(); // 注释掉，避免覆盖轮播图
			// this.get_Indexdata(); // 注释掉，避免覆盖轮播图
			this.get_App_page(); // 只用新接口获取首页数据
			this.setGreeting();
			setTimeout(() => {
				this.getWeather();
				this.get_unread();
			}, 1000);
			this.os = uni.getSystemInfoSync().osName;
			if (uni.getStorageSync("userName") && uni.getStorageSync("password")) {
				let self = this;
				uni.getPushClientId({
					success(res) {
						self.push_id = res.cid;
					}
				})
			}
		},
		// onShow() {

		// },
		onPageScroll(e) {

			if (e.scrollTop > 10) {
				this.head_back = "background-color:white";
			} else {
				this.head_back = "";
			}
		},

		methods: {
			toLink(url) {
			this.$comm.nav_to(url, "", "nav", true);
		},
			navigateTo(item, isTab) {
				let url = '';
				let title = '';
				// 兼容字符串和对象
				if (typeof item === 'string') {
					url = item;
				} else if (item && typeof item === 'object') {
					url = item.url;
					title = item.title || '';
				}
				if (!url) {
					uni.showToast({ title: '敬请期待', icon: 'none' });
					return;
				}
				// 外链/特殊类型 - 根据新的数据结构调整判断逻辑
				if (item && (item.url_type === '11' || url.startsWith('http'))) {
					const encodeUrl = encodeURIComponent(url);
					const back = encodeURIComponent('pages/switchPages/main');
					const encodeTitle = encodeURIComponent(title);
					uni.navigateTo({
						url: `/pages/web/web?token=true&url=${encodeUrl}&back=${back}&title=${encodeTitle}`
					});
					return;
				}
				// 普通页面跳转
				this.$comm.nav_to(url, title, 'nav', true);
			},
			// list_login() {
			// 	let self = this
			//
			// 	console.log('self.push_id: ', self.push_id);
			//
			// 	let data = {
			// 		userName: uni.getStorageSync("userName"),
			// 		password: self.$lg.base64encode(uni.getStorageSync("ld").p),
			// 	}
			// 	// let data={};
			// 	// #ifdef APP-PLUS
			// 	data["devicesId"] = self.push_id;
			// 	// #endif
			// 	data["ttsxAuthSign"] = sign.sign(data).toString();
			// 	console.log("login.data", data);
			//
			//
			//
			// 	// #ifdef H5
			// 	console.log('执行了H5')
			// 	// url = "/test/APP/app/login";
			// 	// #endif
			// 	if (self.push_id) {
			// 		data["push_id"] = self.push_id;
			// 	}
			// 	data["os"] = self.os;
			//
			// 	console.log('数据datadatadata：', data);
			// 	self.$boya.NPost("/app/login", data, function(res) {
			// 		console.log("登录成功-->res", res);
			// 		// self.login_ok(res);
			// 	}, function(err) {
			// 		console.log("登录失败-->err", err);
			// 		if (err) {
			// 			if (err.msg.indexOf("参数校验失败") == -1) {
			// 				uni.showToast({
			// 					icon: "none",
			// 					title: err.msg
			// 				});
			// 			}
			// 		} else {
			// 			self.$boya.msg("自动登录失败!");
			// 			uni.reLaunch({
			// 				url: "/pages/login/login?logout=1"
			// 			})
			// 		}
			// 	}, {
			// 		showError: false
			// 	})
			// },
			// login_ok(res) {
			// 	console.log("login_ok: ", res);
			// 	uni.setStorageSync("ttsxAuthToken", res.data.ttsxAuthToken);
			// 	uni.setStorageSync("userInfo", res.data.user);
			// 	uni.setStorageSync("uuid", res.data.uuid);
			// 	console.log("uuid", res.data.uuid);
			// 	uni.setStorageSync("member", res.data.member);
			// 	uni.setStorageSync("platformMall", "c69a70c5-de6f-44fa-a333-88c5a5b3ff77")
			// },
			// 天气
			getWeather() {
				let self = this
				let city = null
				console.log(self.user);
				if (self.user == '' || self.user == null || self.user == undefined) return;
				if (self.user.orga.name.includes('广钢')) {
					city = '防城港'
				} else if (self.user.orga.name.includes('中金')) {
					city = '玉林'
				} else {
					city = '柳州'
				}
				let data = {
					city: city
				}

				this.$boya.NGet('/app/weather', data, function(res) {
					// console.log('天气-------1: ', res.data[0]);
					self.weather = res.data[0]
					console.log('天气-------2: ', self.weather);
				}, null, {
					showError: false
				})
			},

			setGreeting() {
				const now = new Date();
				const hour = now.getHours();

				if (hour >= 18 || hour < 6) {
					this.greeting = "晚上好";
				} else if (hour >= 6 && hour < 12) {
					this.greeting = "早上好";
				} else if (hour >= 12 && hour < 14) {
					this.greeting = "中午好";
				} else if (hour >= 14 && hour < 18) {
					this.greeting = "下午好";
				}
			},
			my_notice() {
				this.$boya.NGet("/app/msg_info/unread", {
					lock_state: 0
				}, (res) => {
					console.log("my_notice", res);
					if (res.data.length > 0) {
						// #ifdef APP-PLUS
						plus.push.createMessage("您有" + res.data.length + "条信息未读", {}, {
							cover: true,
							title: '消息提醒',
							sound: 'system',

						});
						// #endif
						uni.showModal({
							title: "提示",
							content: "您有" + res.data.length + "条消息未读",
							confirmText: "查看",
							cancelText: "关闭",
							success(e) {
								console.log(e);
								if (e.confirm) {
									uni.navigateTo({
										url: "/pages/home/message/message?type=1"
									})
								}
							}
						})
					}
				}, null, {
					showLoading: false
				});
			},

			get_unread() {
				// console.log('获取消息提示');
				let self = this;
				// #ifdef APP-PLUS
				this.$boya.NGet("/app/msg_info/unread", {}, (res) => {
					let msgcount = uni.getStorageSync("msgCount");
					if (msgcount != res.data) {
						msgcount = res.data
						console.log("#####get_unread->res", res.data)
						self.unread = res.data

						if (res.data > 0) {
							if (self.is_push == false) {
								self.is_push = true;
								plus.push.createMessage("您有" + res.data + "条信息未读", {}, {
									cover: true,
									title: '消息提醒',
									sound: 'system',

								});
							}
						}
					}
					let nav1 = self.$refs.page1.get_ref("nav1");
					nav1[0].badge(3, msgcount);
					self.unread = msgcount
					plus.runtime.setBadgeNumber(msgcount);
					console.log(self.unread);
				}, null, {
					showLoading: false
				})
				// #endif
			},
			aoedit_event(e) {
				console.log("index.aoedit_event", e);
				switch (e.type) {
					case "storenotecard":
						this.storenotecard_event(e.event)
						break;
				}
			},
			storenotecard_event(e) {
				if (e.type == "category_change") {
					this.get_news(e.value);
				}
			},



			navchange(index) {
				this.navIndex = index;
				this.newslist = [];
				this.get_news(this.navList[index].id);
			},

			get_news(id) {
				let self = this;
				let parm = null;
				if (id) {
					parm = {
						"category_id": id
					};
				}
				this.$boya.NGet("/app/news", parm, function(res) {
					// console.log(res);
					self.news(res.data.data, parm);
				});
			},
			news(res, parm = null) {

				let list = [];
				if (res) {
					for (let key in res) {
						let item = res[key];
						let ditem = {
							src: this.$uimg + item.fid,
							text: item.title,
							linktype: 10,
							reads: item.look_num,
							likes: item.is_relay,
							http: {
								externalLink: "#/pages/news/newsDetail?id=" + item.id
							}
						};
						list.push(ditem);
					}
					this.newslist = list;

					this.$refs.page1.setData("articleList", this.newslist);
					if (parm) {
						if (parm.hasOwnProperty("category_id")) {
							this.$refs.page1.setData("articleList", parm.category_id, category_id);
						}
					}
					//this.$refs.page1.update_ref("articleList");
				}
			},

			//特色专题等
			update_page() {
				let self = this;

				this.$comm.get_appPages(function(res) {
					// console.log("update_page", res);
					if (res.ver != self.pageConfig.ver) {
						self.pageConfig = res;
						// uni.setStorageSync("pages_首页", res);
						try {
							self.$refs.page1.setPageConfig(res);
							console.log("update_page", "更新");
						} catch {
							this.nextTick(() => {
								self.$refs.page1.setPageConfig(res);
							})

						}

						self.set_indexData();
						if (self.debug) {

							uni.showToast({
								title: "更新完毕",
								icon: "none"
							})
						}
					}


				}, false, "首页");
			},
			init_pages(fnc) {
				let d = uni.getStorageSync("pages_首页");
				// console.log("pages_首页", d);
				this.get_Indexdata();
			},
			get_Indexdata() {
				this.$boya.NGet("/app/index", null, (res) => {
					this.set_indexData(res.data);
					console.log("ce",res.data)
				}, null, {
					showLoading: false
				})

				
			},
			get_App_page() {
				this.$boya.NGet("/app/getMenu", null, (res) => {
					// 这里直接判断 res.data 是否为数组
					if (res && Array.isArray(res.data)) {
						// 处理导航区等数据
						const allItems = res.data;
						
						// 图文导航板块一
						const navCategory = allItems.find(item => item.name === '图文导航');
						if (navCategory && Array.isArray(navCategory.app_menu)) {
							this.functionItems = navCategory.app_menu
								.filter(item => item.enable === 1)
								.sort((a, b) => a.sort - b.sort)
								.map(item => ({
									id: item.id,
									text: item.title,
									icon: item.icon,
									url: item.url || '',
									url_type: item.url_type,
									raw: item
								}));
						}

						// 图文导航板块二
						const gridCategory = allItems.find(item => item.name === '首页菜单');
						if (gridCategory && Array.isArray(gridCategory.app_menu)) {
							this.functionGrid = gridCategory.app_menu
								.filter(item => item.enable === 1)
								.sort((a, b) => a.sort - b.sort)
								.map(item => ({
									id: item.id,
									title: item.title,
									icon: item.icon,
									url: item.url || '',
									url_type: item.url_type,
									raw: item
								}));
						}

						// 魔方
						const magicCubeCategory = allItems.find(item => item.name === '首页魔方');
						if (magicCubeCategory && Array.isArray(magicCubeCategory.app_menu)) {
							this.magicCubeItems = magicCubeCategory.app_menu
								.filter(item => item.enable === 1)
								.sort((a, b) => a.sort - b.sort)
								.map(item => ({
									id: item.id,
									title: item.title,
									icon: item.icon,
									url: item.url || '',
									url_type: item.url_type,
									raw: item
								}));
						}

						// 图文广告
						const adCategory = allItems.find(item => item.name === '首页胶囊');
						if (adCategory && Array.isArray(adCategory.app_menu)) {
							this.adItems = adCategory.app_menu
								.filter(item => item.enable === 1)
								.sort((a, b) => a.sort - b.sort)
								.map(item => ({
									id: item.id,
									title: item.title,
									image: item.icon,
									link: item.url || '',
									url_type: item.url_type,
									raw: item
								}));
						}

						// 轮播图数据
						this.set_indexData(allItems);
						console.log("首页数据", res.data);
					} else {
						this.swiperList = [];
						this.functionItems = [];
						this.functionGrid = [];
						this.magicCubeItems = [];
						this.adItems = [];
						console.log("无数据返回", res);
					}
				}, (err) => {
					this.swiperList = [];
					this.functionItems = [];
					this.functionGrid = [];
					this.magicCubeItems = [];
					this.adItems = [];
					console.log("请求失败", err);
				}, {
					showLoading: false
				});
			},
			set_indexData(data) {
				// 只处理新接口返回的轮播图数据
				if (Array.isArray(data)) {
					const bannerCategory = data.find(item => item.name === '轮播图');
					if (bannerCategory && Array.isArray(bannerCategory.app_menu)) {
						const bannerItems = bannerCategory.app_menu.filter(item => item.enable === 1);
						if (bannerItems.length > 0) {
							this.swiperList = bannerItems.sort((a, b) => a.sort - b.sort).map(item => {
								let externalLink = '';
								if (item.url) {
									if (item.url.startsWith('http')) {
										const encodeUrl = encodeURIComponent(item.url);
										externalLink =
											`#/pages/web/web?token=true&url=${encodeUrl}&title=${encodeURIComponent(item.title)}`;
									} else {
										externalLink = `#/pages/news/newsDetail?id=${item.url}`;
									}
								}
								let imgSrc = item.icon;
								if (imgSrc && !imgSrc.startsWith('https')) {
									if (imgSrc.startsWith('/storage/')) {
										imgSrc = config.local + imgSrc;
									}
								}
								return {
									src: imgSrc,
									text: item.title,
									linktype: '10',
									http: {
										externalLink: externalLink
									},
									link: item.url
								};
							});
						} else {
							this.swiperList = [];
						}
					} else {
						this.swiperList = [];
					}
				}
				// 处理 functionItems
				if (Array.isArray(this.functionItems)) {
					this.functionItems = this.functionItems.map(item => {
						let imgSrc = item.icon;
						if (imgSrc && !imgSrc.startsWith('https')) {
							if (imgSrc.startsWith('/storage/')) {
								imgSrc = config.local + imgSrc;
							}
						}
						return { ...item, icon: imgSrc };
					});
				}
				// 处理 functionGrid
				if (Array.isArray(this.functionGrid)) {
					this.functionGrid = this.functionGrid.map(item => {
						let imgSrc = item.icon;
						if (imgSrc && !imgSrc.startsWith('https')) {
							if (imgSrc.startsWith('/storage/')) {
								imgSrc = config.local + imgSrc;
							}
						}
						return { ...item, icon: imgSrc };
					});
				}
				// 处理 magicCubeItems
				if (Array.isArray(this.magicCubeItems)) {
					this.magicCubeItems = this.magicCubeItems.map(item => {
						let imgSrc = item.icon;
						if (imgSrc && !imgSrc.startsWith('https')) {
							if (imgSrc.startsWith('/storage/')) {
								imgSrc = config.local + imgSrc;
							}
						}
						return { ...item, icon: imgSrc };
					});
				}
				// 处理 adItems
				if (Array.isArray(this.adItems)) {
					this.adItems = this.adItems.map(item => {
						let imgSrc = item.image;
						if (imgSrc && !imgSrc.startsWith('https')) {
							if (imgSrc.startsWith('/storage/')) {
								imgSrc = config.local + imgSrc;
							}
						}
						return { ...item, image: imgSrc };
					});
				}
			},
			scrolltoupper(e) {

				this.head_back = "";
			},
			scroll(e) {
				// console.log("scroll",e);
				if (e.detail.deltaY < -0.1) {
					this.head_back = "background-color:white";
					// console.log("scroll",e);
				}
			},
			showPopup1() {
				this.showPopup = true
				// console.log('--12-1-')
			},
			// sleep_data() {

			// },
			category_news(res) {
				// console.log("category_news",res)
				let arr = [];

				this.$refs.page1.setData("articleList", res, "categorys");

				// console.log("category_news", this.navList, this.allList);
			},
			notice(res) {
				let arr = [];
				for (let key in res) {
					// { title: "lesscode.work - 精品 IT 课程中心", url: "../index/index", opentype: "switchTab"}
					let item = res[key];
					arr.push({
						title: item.title,
						url: '/pages/home/notice/index?id=' + item.id,
						opentype: "navigate"
					})
				}
				this.$nextTick(() => {
					let gg = this.$refs.page1.get_ref("gg");
					if (gg) {
						gg.items = arr;
					}
				})

			},

			swiper(res) {

				this.swiperItems = [];
				this.swiperData = res;
				let linktype = '10';
				for (let key in res) {
					let item = res[key];
					let uimg = JSON.parse(item.index_url_app);
					let url = "#/pages/news/newsDetail?id=" + item.link;



					this.swiperItems.push({
						src: this.$uimg + uimg.id,
						text: item.title,
						linktype: linktype,
						http: {
							externalLink: url
						}
					})

				}

				this.$refs.page1.setData("lbt", this.swiperItems);
			},


			page_style() {
				let _style = this.page.templateJson.Style;
				if (this.page.templateJson.bgColor != "") {
					_style.backgroundColor = this.page.templateJson.bgColor
				}
				if (this.page.templateJson.bgImg != "") {
					_style.backgroundImage = "url(" + this.page.templateJson.bgImg + ")"
				}
				return _style;
			},
			handleSwiperTap(item) {
				// 优先用 http.externalLink 跳转
				if (item.http && item.http.externalLink) {
					// H5/小程序内跳转
					if (item.http.externalLink.startsWith('#/')) {
						// uni.navigateTo 只支持以 / 开头的路径，去掉 #
						let url = item.http.externalLink.replace(/^#/, '');
						uni.navigateTo({ url });
					} else {
						// 外链或其他类型
						window.location.href = item.http.externalLink;
					}
				} else if (item.link) {
					// 兜底：有 link 字段也跳转
					uni.navigateTo({ url: `/pages/news/newsDetail?id=${item.link}` });
				} else {
					// 没有可跳转内容
					uni.showToast({ title: '暂无跳转链接', icon: 'none' });
				}
			},
			handleFunctionTap(item) {
				let url = item.url.replace(/^#/, '');
				uni.navigateTo({ url });
			},
			toggleFunctionGrid() {
				this.isGridExpanded = !this.isGridExpanded;
			},
			get_menu() {
				let menu = uni.getStorageSync("index_menu");
				console.log("缓存的菜单数据:", menu, "是否为数组:", Array.isArray(menu));
				if (menu && Array.isArray(menu)) {
					this.functionGrid = menu;
					console.log('functionGrid from cache:', this.functionGrid);
				} else {
					this.functionGrid = [];
				}
				this.$boya.NGet("/app/get_menu?category=home_top", null, (res) => {
					console.log("菜单接口返回:", res);
					if (res.data && res.data.length > 0) {
						const menuData = res.data[0].app_menu;
						console.log("提取的菜单数据:", menuData, "是否为数组:", Array.isArray(menuData));
						if (Array.isArray(menuData)) {
							this.functionGrid = menuData;
							uni.setStorageSync("index_menu", this.functionGrid);
							console.log("成功设置菜单数据，数量:", this.functionGrid.length);
							console.log('functionGrid from api:', this.functionGrid);
						} else {
							console.warn("接口返回的菜单数据不是数组:", menuData);
							this.functionGrid = [];
						}
					} else {
						console.warn("接口返回的数据格式异常:", res);
						this.functionGrid = [];
					}
				});
			},
			onCustomerService() {
				// 跳转到客服反馈页面
				uni.navigateTo({ url: '/pages/other/feedback/feedback' });
			}
		}
	}
</script>
<style>

	.app {
		position: relative;
		height: 100vh;
		/* overflow-y: scroll; */
	}

	.head {
		height: calc(var(--status-bar-height)+70rpx);
		z-index: 99999;

		width: 100%;
		position: fixed;
		top: var(--window-top);
		padding-top: var(--status-bar-height);
		padding-left: 20rpx;
		padding-right: 140rpx;
		padding-bottom: 10rpx;
		align-items: center;
	}

	/* 快捷功能区 */
	.quick-functions {
		display: flex;
		flex-direction: column;
		background-color: #1e88e5;
		background-size: 100% 100%;
		background-position: top center;
		background-repeat: no-repeat;
		position: relative;
		height: 480rpx; /* 或更高，根据实际效果调整 */
	}

	.functions-wrap {
		display: flex;
		justify-content: space-around;
		align-items: center;
		padding: 0 20rpx 20rpx;
		margin-top: 50rpx;
	}

	.function-item {
		display: flex;
		flex-direction: column;
		align-items: center;
		z-index: 2;
	}

	.function-icon {
		width: 100rpx;
		height: 100rpx;
		margin-bottom: 12rpx;
	}

	.function-text {
		font-size: 28rpx;
		color: #ffffff;
		font-weight: bold;
	}

	/* 轮播图 */
	.swiper-container {
		width: 100%;
		padding: 0 20rpx;
		box-sizing: border-box;
		margin-top: 20rpx;
	}

	.swiper {
		height: 300rpx !important;
		/* background: #ffcccc !important; */
		border-radius: 20rpx;
		overflow: hidden;
	}

	.swiper-item {
		width: 100%;
		height: 100%;
		border-radius: 20rpx;
	}

	/* 功能导航网格 */
	.function-grid {
		padding: 10rpx;
		background-color: #ffffff;
		margin: 20rpx;
		border-radius: 20rpx;
		position: relative;
		border: 1px solid #f0f0f0;
		box-shadow: 0 2rpx 6rpx rgba(0, 0, 0, 0.1);
	}

	.grid-container {
		display: flex;
		flex-wrap: wrap;
	}

	.grid-item {
		width: 20%;
		display: flex;
		flex-direction: column;
		align-items: center;
		margin-bottom: 30rpx;
	}

	.grid-icon {
		width: 80rpx;
		height: 80rpx;
		margin-bottom: 10rpx;
	}

	.grid-text {
		font-size: 24rpx;
		color: #333333;
	}

	/* 展开/收起按钮 */
	.expand-btn {
		display: flex;
		align-items: center;
		justify-content: center;
		margin-top: -20rpx;
		cursor: pointer;
	}

	.expand-icon {
		/* 图标样式 */
	}

	/* 广告轮播 */
	.ad-container {
		width: 100%;
		padding: 0 20rpx;
		box-sizing: border-box;
		margin-top: 20rpx;
	}

	.ad-image {
		width: 100%;
		border-radius: 10rpx;
		box-shadow: 0 2rpx 6rpx rgba(0, 0, 0, 0.1);
	}

	/* 通知区域 */
	.notice-section {
		width: 90%;
		margin: 0 auto;
		padding: 20rpx;
		margin-top: 20rpx;
		border: 1px solid #d8d8d8;
		border-radius: 20rpx;
		box-shadow: 3rpx 5rpx 8rpx rgba(0, 0, 0, 0.2);
	}

	.notice-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.notice-title {
		display: flex;
		align-items: center;
	}

	.title-icon {
		width: 120rpx;
		height: 80rpx;
		margin-right: 10rpx;
	}

	.title-text {
		font-size: 30rpx;
		font-weight: bold;
	}

	.scroll-container {
		width: 430rpx;
		font-size: 28rpx;
		/* 设置容器宽度，根据需要进行调整 */
		overflow: hidden;
		/* 隐藏超出容器宽度的文字 */
		margin-left: 15rpx;
	}

	#scroll-text {
		white-space: nowrap;
		/* 设置文字不换行 */
		display: inline-block;
		/* 必须将文字包裹在一个块级元素中，才能进行动画效果 */
		animation: scroll-left 8s linear infinite;
		/* 设置文字动画效果 */
	}

	@keyframes scroll-left {
		0% {
			transform: translateX(100%);
			/* 初始位置为容器宽度的100%，文字隐藏在容器右侧 */
		}

		100% {
			transform: translateX(-100%);
			/* 结束位置为容器宽度的-100%，文字完全滚出容器左侧 */
		}
	}

	.more-link {
		font-size: 24rpx;
		color: #2196f3;
	}

	/* 特色专题 */
	.special-section {
		padding: 20rpx;
		margin-top: 20rpx;
	}

	.section-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 20rpx;
	}

	.section-header-bg {
		background-image: url('/static/tesebj.png');
		background-size: cover;
		background-position: center;
		background-repeat: no-repeat;
		height: 60rpx;
		display: flex;
		align-items: center;
		border-radius: 10rpx;
		padding: 0 20rpx;
	}
	.section-title-left {
		display: flex;
		align-items: center;
	}
	.section-logo {
		width: 40rpx;
		height: 40rpx;
		margin-right: 10rpx;
	}
	.section-text {
		font-size: 30rpx;
		font-weight: bold;
		color: #fff;
		text-shadow: 0 2rpx 6rpx rgba(0,0,0,0.2);
	}

	.special-content {
		display: flex;
		justify-content: space-between;
		margin-bottom: 20rpx;
	}

	.second-row {
		justify-content: flex-start;
	}

	.second-row .special-item {
		width: 30%;
		margin-right: 3.3%;
	}

	.second-row .special-item:last-child {
		margin-right: 0;
	}

	.special-item {
		width: 48%;
		height: 160rpx;
		background-color: #ffffff;
		border-radius: 10rpx;
		padding: 20rpx;
		box-shadow: 0 2rpx 6rpx rgba(0, 0, 0, 0.1);
		position: relative;
		overflow: hidden;
	}

	.blue-item {
		background-color: #e3f2fd;
	}

	.pink-item {
		background-color: #fce4ec;
	}

	.orange-item {
		background-color: #fff3e0;
	}

	.special-text {
		margin-bottom: 10rpx;
	}

	.special-title {
		font-size: 28rpx;
		font-weight: bold;
		color: #333333;
	}

	.special-desc {
		font-size: 22rpx;
		color: #666666;
		margin-top: 4rpx;
	}

	.special-btn {
		position: absolute;
		bottom: 20rpx;
		left: 20rpx;
		padding: 6rpx 20rpx;
		color: #ffffff;
		border-radius: 30rpx;
		font-size: 24rpx;
	}

	.blue-btn {
		background-color: #2196f3;
	}

	.pink-btn {
		background-color: #ec407a;
	}

	.orange-btn {
		background-color: #ff9800;
	}

	.special-icon {
		position: absolute;
		bottom: 20rpx;
		right: 20rpx;
		width: 60rpx;
		height: 60rpx;
	}

	.special-item.flower-icon {
		width: 60rpx;
		height: 60rpx;
	}

	/* 职工文化作品展 */
	.exhibition-container {
		width: 100%;
		padding: 0 20rpx;
		box-sizing: border-box;
		margin-top: 20rpx;
	}

	.exhibition-image {
		width: 100%;
		border-radius: 10rpx;
		box-shadow: 0 2rpx 6rpx rgba(0, 0, 0, 0.1);
	}

	/* 新闻资讯 */
	.news-section {
		padding: 20rpx;
		margin: 20rpx;
		background-color: #fff;
		border-radius: 10rpx;
	}

	.news-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 10rpx;
	}

	.news-title-wrap {
		display: flex;
		align-items: center;
	}

	.news-icon {
		width: 40rpx;
		height: 40rpx;
		margin-right: 10rpx;
	}

	.news-title {
		font-size: 30rpx;
		font-weight: bold;
	}

	.news-more {
		font-size: 24rpx;
		color: #999;
	}

	.news-tabs {
		display: flex;
		border-bottom: 1px solid #eee;
		padding: 0 0 10rpx 0;
		margin-bottom: 20rpx;
		position: relative;
		align-items: center;
	}

	.scroll-view-x {
		width: calc(100% - 140rpx);
		white-space: nowrap;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none;
		/* Firefox */
	}

	.scroll-view-x::-webkit-scrollbar {
		display: none;
		/* Chrome, Safari */
	}

	.tabs-container {
		display: inline-flex;
		padding-right: 20rpx;
	}

	.tab-item {
		font-size: 28rpx;
		color: #333;
		margin-right: 40rpx;
		padding-bottom: 10rpx;
		position: relative;
		display: inline-block;
		white-space: nowrap;
		flex-shrink: 0;
	}

	.tab-item.active {
		color: #2196f3;
		font-weight: bold;
		border-bottom: 2px solid #2196f3;
	}

	.tab-item.active:after {
		content: "";
		position: absolute;
		bottom: -10rpx;
		left: 0;
		width: 100%;
		height: 4rpx;
		background-color: #2196f3;
	}

	.tabs-right-btns {
		display: flex;
		position: absolute;
		right: 0;
		background-color: #fff;
		padding-left: 10rpx;
		z-index: 1;
	}

	.tab-item.circular {
		margin-right: 10rpx;
	}

	.tab-item.menu-btn {
		margin-right: 0;
	}

	.circular-icon,
	.menu-icon {
		width: 60rpx;
		height: 60rpx;
	}

	.news-list {
		display: flex;
		flex-direction: column;
	}

	.news-item {
		display: flex;
		justify-content: space-between;
		padding: 20rpx 0;
		border-bottom: 1px solid #f5f5f5;
	}

	.news-item:last-child {
		border-bottom: none;
	}

	.news-content {
		flex: 1;
		margin-right: 20rpx;
	}

	.news-item-title {
		font-size: 28rpx;
		color: #333;
		margin-bottom: 15rpx;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	.news-info {
		display: flex;
		font-size: 25rpx;
		color: #999;
	}

	.news-time {
		margin-right: 20rpx;
	}

	.news-source {
		color: #666;
	}

	.news-thumb {
		width: 180rpx;
		height: 120rpx;
		border-radius: 6rpx;
		object-fit: cover;
	}

	/* 页面底部版权信息 */
	.footer-info {
		width: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
		padding: 30rpx 0;
		margin-top: 20rpx;
	}

	.copyright,
	.beian {
		font-size: 28rpx;
		color: #999;
		line-height: 1.6;
		text-align: center;
	}

	.links {
		display: flex;
		justify-content: center;
		margin-top: 10rpx;
	}

	.link-item {
		font-size: 28rpx;
		color: #999;
	}

	.separator {
		padding: 0 10rpx;
		color: #999;
		font-size: 28rpx;
	}

	.fixed-persons {
		position: fixed;
		right: 30rpx;
		bottom: 40rpx;
		display: flex;
		flex-direction: column;
		align-items: flex-end;
		z-index: 9999;
	}
	.person-img {
		width: 120rpx;
		height: 120rpx;
		margin-top: 20rpx;
		box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.15);
		border-radius: 20rpx;
		background: #fff;
	}
	.fixed-persons .person-img:first-child {
		margin-top: 0;
	}
.quick-functions {
  position: relative;
}
.quick-persons {
  position: absolute;
  right: 30rpx;
  bottom: 30rpx;
  display: flex;
  flex-direction: row; /* 横向排列 */
  align-items: flex-end;
  z-index: 10;
}

.person-img {
  width: 83px;
  height: 152px;
  margin-left: 16rpx; /* 横向间距 */
  margin-top: 0;
  border-radius: 16rpx;
  background: none; /* 去除背景色 */
  box-shadow: none; /* 去除阴影 */
}

.quick-persons .person-img:first-child {
  margin-left: 0;
}
.swiper-customer-btn {
  position: fixed;
  right: 0rpx;
  bottom: 850rpx; /* 向上移动 */
  width: 60rpx;
  height: 60rpx;
  z-index: 10000;
  background: rgba(255,255,255,0.7);
  box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.10);
  border-radius: 50%;
  padding: 10rpx;
  display: flex;
  align-items: center;
  justify-content: center;
}
</style>